package com.thirteengroup.casemg.domain;

import java.util.List;

public class PageResult<T> {

    private int currentPage;
    private int totalConut;
    private int pageSize;
    private int nextPage;
    private int prePage;
    private int totalPage;
    private List<T> data;

    public PageResult(int currentPage, int totalConut, int pageSize, List<T> data) {
        this.currentPage = currentPage;
        this.totalConut = totalConut;
        this.pageSize = pageSize;
        this.data = data;


        if(this.totalConut % this.pageSize==0){
            this.totalPage=this.totalConut / this.pageSize;
        }else {
            this.totalPage=(this.totalConut / this.pageSize) + 1;
        }

        if(this.currentPage==1){
            this.prePage=1;
        }else {
            this.prePage=this.currentPage-1;
        }

        if(this.currentPage+1<=this.totalPage){
            this.nextPage=this.currentPage+1;
        }else {
            this.nextPage=this.totalPage;
        }
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getTotalConut() {
        return totalConut;
    }

    public void setTotalConut(int totalConut) {
        this.totalConut = totalConut;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getNextPage() {
        return nextPage;
    }

    public void setNextPage(int nextPage) {
        this.nextPage = nextPage;
    }

    public int getPrePage() {
        return prePage;
    }

    public void setPrePage(int prePage) {
        this.prePage = prePage;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }
}
